//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.liy.framework.web.spring.context;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;



/**
 *
 *
**/
@Component
public class ApplicationContextProvider implements ApplicationContextAware {

    private static ApplicationContext context;    // 应用上下文

    public ApplicationContextProvider() {
    }

    public static ApplicationContext getApplicationContext() {
        return context;
    }

    public void setApplicationContext(ApplicationContext ac) throws BeansException {
        context = ac;
    }


    /**
     * 获取容器中的 实例  tClass
     *
     **/
    public static <T> T getBean(Class<T> tClass) {
        return context.getBean(tClass);
    }

    /**
     * 获取容器中的 实例  name,  tClass
     *
     **/
    public static <T> T getBean(String name, Class<T> tClass) {
        return context.getBean(name, tClass);
    }
}
